package com.bosssoft.ecds.service.impl;

import com.bosssoft.ecds.entity.vo.FbeStockFinanceapplyCheckVO;
import com.bosssoft.ecds.util.EntityUtil;
import com.bosssoft.ecds.entity.po.FbeStockFinanceapplyCheckPO;
import com.bosssoft.ecds.entity.po.FbeStockFinanceapplyItemPO;
import com.bosssoft.ecds.entity.vo.FbeStockFinanceapplyItemVO;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 张东海
 * @date 2020/8/13
 * @description 财政端RabbitMQ监听服务，用于监听并接收消息队列中的
 *               来自单位端的票据申请记录，以及票据申请记录所对应的
 *               申请具体票据信息
 */
@Service
public class ConsumerService {

    @Resource
    FbeStockFinanceapplyCheckServiceImpl fbeStockFinanceapplyCheckService;

    @Resource
    FbeStockFinanceapplyItemServiceImpl fbeStockFinanceapplyItemService;

    @RabbitListener(queues = "dfQ")
    public void receive(FbeStockFinanceapplyCheckVO financeapplyVO){
        FbeStockFinanceapplyCheckPO financeapplyCheckPO = new FbeStockFinanceapplyCheckPO();
        EntityUtil.VOToPO(financeapplyVO,financeapplyCheckPO);
        fbeStockFinanceapplyCheckService.insert(financeapplyCheckPO);
    }

    @RabbitListener(queues = "dfItemQ")
    public void receiveItem(FbeStockFinanceapplyItemVO financeapplyItemVO){
        FbeStockFinanceapplyItemPO financeapplyItemPO = new FbeStockFinanceapplyItemPO();
        EntityUtil.VOToPO(financeapplyItemVO,financeapplyItemPO);
        fbeStockFinanceapplyItemService.insert(financeapplyItemPO);
    }

}
